package com.bems.service;

import java.sql.Timestamp;

import com.bems.dao.ListDao;
import com.bems.pojo.Code;
import com.bems.pojo.List;
import com.bems.util.PageUtil;

/**
 *  清单信息
 * @author 陈磊
 *
 */
public class ListService 
{
	
	
	public boolean out(List list,java.util.List<Code> codes) 
	{
		list.setId(0);
		Long ret ;
		if (codes!=null) {
			ret=listDao.out(list, codes);
		}
		else {
			ret=listDao.out(list);
		}
	
		return ret>0?true: false;
		
	}
	
		
			/**
			 *   添加清单
			 * @param list 清单
			 * @param codes 一维码
			 * @return
			 */
				public boolean add(List list,java.util.List<Code> codes) 
				{
					list.setId(0);
					Long ret ;
					if (codes!=null) 
					{
						ret=listDao.save(list, codes);
					}
					else {
						ret=listDao.save(list);
					}
				
					return ret>0?true: false;
					
				}
				
				/**
				 *   返回page 
				 * @param status 库存状态
				 * @param start
				 * @param end
				 * @param page
				 * @param size
				 * @return
				 */
				public PageUtil getLists(int status,Timestamp start,Timestamp end,int page,int size) 
				{
					PageUtil pageUtil = new PageUtil();
					pageUtil.setList(listDao.getLists(page, size, start, end,status));
					pageUtil.setPage(page);
					pageUtil.setSize(size);
					String filter=" status="+status+" warehouse_id =1 and UNIX_TIMESTAMP(createtime) between  UNIX_TIMESTAMP('"+start+"') and UNIX_TIMESTAMP('"+end+"') ";
					pageUtil.setTotalpage(new List().totalCount(filter));		
					return pageUtil;
					
				}
				
				
				/**
				 *   返回page 
				 * @param status 库存状态
				 * @param page
				 * @param size
				 * @return
				 */
				public PageUtil getLists(int status,int page,int size) 
				{
					PageUtil pageUtil = new PageUtil();
					pageUtil.setList(listDao.getLists(page,size,status));
					pageUtil.setPage(page);
					pageUtil.setSize(size);
					String filter=" status="+status+" warehouse_id =1  ";
					pageUtil.setTotalpage(new List().totalCount(filter));		
					return pageUtil;
					
				}
				public PageUtil getListt(int type,int page,int size) 
				{
					PageUtil pageUtil = new PageUtil();
					pageUtil.setList(listDao.getListt(page,size,type));
					pageUtil.setPage(page);
					pageUtil.setSize(size);
					String filter="status=1 and type_id="+type+" warehouse_id =1  ";
					pageUtil.setTotalpage(new List().totalCount(filter));		
					return pageUtil;
					
				}
				
				ListDao listDao = new ListDao();
}
